Add Blitz cache cleanup task for Craft CMS deployments#24
Conversation
Co-authored-by: kevinsleegerslameco <217211989+kevinsleegerslameco@users.noreply.github.com>
| set('lameco_php_config', 'php-fpm-{{http_user}}.service'); | ||
|
|
||
| // Blitz cache cleanup configuration | ||
| set('lameco_cleanup_blitz_cache', true); |
There was a problem hiding this comment.
@copilot I don't think that this has to be configurable. I would just assume for it to work automatically if the project type is craft cms.
There was a problem hiding this comment.
Removed the configuration parameter. The task now runs automatically for all Craft CMS projects. (16043f3)
|
|
||
| // Get the current release name and all releases | ||
| $currentRelease = basename(run('readlink {{deploy_path}}/current')); | ||
| $releases = explode("\n", run('ls -1 {{deploy_path}}/releases')); |
There was a problem hiding this comment.
@copilot If this works fine. But can you check if there's a built-in way in deployer to get the current release and other releases?
There was a problem hiding this comment.
Updated to use Deployer's built-in functions: get('release_name') for the current release and get('releases_list') for all releases. This replaces the manual readlink and ls commands. (16043f3)
|
@copilot can you take a look at the reviews? |
Co-authored-by: kevinsleegerslameco <217211989+kevinsleegerslameco@users.noreply.github.com>
This PR adds automated cleanup of Blitz cache files from old releases during Craft CMS deployments to prevent storage bloat and maintain optimal server performance.
What's Changed
New Task:
lameco:cleanup_blitz_cacheAdded a new deployment task that:
lameco_project_type === 'craftcms'deploy:successto ensure the deployment completed before cleanupweb/cache/blitzfrom all old releases while keeping the current active release untouchedWhy This Is Needed
Blitz is a popular static cache plugin for Craft CMS that stores cached files in
web/cache/blitz. During deployments using Deployer's release system, these cache files accumulate across multiple releases:Since the cache is environment-specific and tied to the current release, old cache files serve no purpose and consume unnecessary disk space. This cleanup ensures only the current release's cache is maintained.
Implementation Details
get('release_name')andget('releases_list')functions for robust release managementDocumentation
Updated README.md with comprehensive documentation including:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.